﻿using UnityEngine;
using System.Collections;

public class InGameFriends : MonoBehaviour 
{
	public Texture texture;

	/// <summary>
	/// The user.
	/// </summary>
	private User user;
	
	/// <summary>
	/// The match.
	/// </summary>
	private Match match;

	private void Start()
	{
		user = User.Instance;
	}
	
	private void CreateMatch(Constants.MatchTypes type)
	{
		if (user.Matches.Count < Constants.MAX_AMOUNT_MATCHES_TOTAL)
		{
			if (user.Matches.Count == Constants.MAX_AMOUNT_MATCHES_WITHOUT_BANNER_MIN || 
			    user.Matches.Count >= Constants.MAX_AMOUNT_MATCHES_WITHOUT_BANNER_MAX)
			{
				// Mostrar BANNER
				
				Debug.Log("BANNER LOCO");
			}
			
			// Poner esto en el callback del BANNER
			match = new Match(user, "Default", type);
			
			user.AddMatch(match);
		}
		else
		{
			Debug.Log("No podes crear mas de 7 GUACHIN");
		}
	}

	private void OnGUI()
	{
		GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), texture);
		
		if (GUILayout.Button("Nuestras Preguntas"))
		{
			CreateMatch(Constants.MatchTypes.Deck);
		}				
		
		if (GUILayout.Button("Nuestras Preguntas + Una Tuya"))
		{
			CreateMatch(Constants.MatchTypes.DeckPlus);
		}	
		
		if (GUILayout.Button("Crea tus Preguntas!"))
		{
			CreateMatch(Constants.MatchTypes.Questions);
		}	
		
		if (GUILayout.Button("Back"))
		{
			Application.LoadLevel(Constants.SCENE_MAIN);
		}
	}
}
